using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace Weathertastic
{
    static class LogConditionIcon
    {
        public static void Log(string Condition, int Icon)
        {
            try
            {
                XmlDocument xFile = new XmlDocument();
                xFile.Load("conditionIcons.xml");
                // <condition name="" icon="" />
                XmlNode NodeToFind = xFile.SelectSingleNode("//condition[@icon=\""+Icon.ToString()+"\"]");
                XmlNode NodeRoot = xFile.SelectSingleNode("//root");
                if (NodeToFind == null)
                {
                    // Create a new node
                    XmlNode NewNode = xFile.CreateNode("element", "condition", null);
                    XmlAttribute AttName = xFile.CreateAttribute("name");
                    AttName.Value = Condition;
                    XmlAttribute AttIcon = xFile.CreateAttribute("icon");
                    AttIcon.Value = Icon.ToString();


                    NewNode.Attributes.Append(AttName);
                    NewNode.Attributes.Append(AttIcon);

                    NodeRoot.AppendChild(NewNode);

                    xFile.Save("conditionIcons.xml");
                }
            }
            catch (Exception)
            {
                
                throw;
            }
        }
    }
}
